﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartSpace.Core
{
    public interface ICoreService
    {
        User GetUser(string account);
        User GetUser(Guid id);
        List<User> GetUsers(List<Guid> idList);
        PagedList<User> GetUsers(int start, int limit);
        PagedList<User> FindUsers(string filter, int start, int limit);

        #region role
        PagedList<Role> GetRoles(int start, int limit);
        Role GetRole(Guid roleId);

        bool SaveRole(Role role);
        bool DeleteRole(Guid roleId);

        bool AssignRoleToUser(Role role, User user, bool isMajor);
        bool RemoveRoleFromUser(Guid roleId, Guid userId);
        bool RemoveRoleFromUser(Guid roleId, string account);

        //PagedList<User> GetUserListByRole(Guid roleId, int start, int limit);
        List<Role> GetRoleListByUser(Guid userId);
        List<Role> GetRoleListByUser(string account);
        #endregion

        bool SaveUser(User user);
        bool DeleteUser(User user);
        bool DeleteUser(Guid userId);

        bool SaveModule(Module module);
        PagedList<Module> GetModules(int start, int limit);
        PagedList<Module> GetModules(string type, int start, int limit);
        Module GetModule(Guid moduleId);
        ModuleView GetView(Guid viewId);

        #region navigation
        bool SaveNavigation(Navigation navigation);
        Navigation GetNavigation(Guid id);
        bool SetDefaultNavigation(Guid id);
        //List<Navigation> GetNavigations(Guid applicationId);
        Navigation GetDefaultNavigation(Guid siteId);

        //List<Navigation> GetNavigations(Guid applicationId, Guid roleId);
        ListResult<Navigation> GetNavigations(Guid siteId);
        ListResult<Navigation> GetNavigations(Guid siteId, Guid pageId);
        //List<Navigation> GetUserNavigations(Guid applicationId, Guid id);
        //List<Navigation> GetUserNavigations(Guid applicationId, string account);
        #endregion

        #region shortcut
        bool AddShortcut(Guid navigationId, string caption);
        bool DeleteShortcut(Guid navigationId);
        List<Shortcut> GetShortcuts(Guid applicationId);
        #endregion

        #region Site
        bool SaveSite(Site site);
        Site GetSite(Guid id);
        Site GetSite(string hostUrl);
        bool DeleteSite(Guid siteId);
        List<Site> GetSites();
        List<Site> GetSites(string type);
        #endregion

        #region modules
        List<Site> GetPersonalApplications(string account);
        Site GetPersonalDefaultApplication(string account);
        List<Site> GetPersonalApplications(string type, string account);
        Site GetPersonalDefaultApplication(string type, string account);
        bool AssignModuleToSite(Guid applicationId, Guid moduleId);
        bool RemoveModuleFromSite(Guid applicationId, Guid moduleId);
        List<Module> GetModules(Guid applicationId);
        #endregion

        #region SiteTemplate
        bool SaveSiteTemplate(SiteTemplate template);
        List<SiteTemplate> GetSiteTemplates();
        List<SiteTemplate> GetSiteTemplates(string type);
        SiteTemplate GetSiteTemplate(Guid id);
        #endregion

        #region Image
        bool SaveImage(Image image);
        bool DeleteImage(Guid imageId);
        Image GetImage(Guid imageId);
        List<Image> GetImages();
        #endregion

        #region privilege
        bool SavePrivilege(Privilege privilege);
        bool DeletePrivilege(Guid id);
        Privilege GetPrivilege(Guid id);
        PagedList<Privilege> GetPrivileges(string codeFilter, int start, int limit);
        PagedList<Privilege> FindPrivileges(string code, int start, int limit);

        ServiceResult AssignPrivilege(Guid privilegeId, Guid ownerId, PrivilegeOwnerType type);
        ListResult<Privilege> GetPrivileges(Guid ownerId, PrivilegeOwnerType type);
        #endregion

        #region usergroup
        bool SaveUserGroup(UserGroup group);
        bool DeleteUserGroup(Guid groupId);
        bool AssignUserToUserGroup(Guid userId, Guid groupId);
        PagedList<User> GetUserGroupContainUsers(Guid id, int start, int limit);
        UserGroup GetUserGroup(Guid groupId);
        List<UserGroup> GetUserGroups();
        #endregion

        #region page
        bool SavePage(VirtualPage page);
        VirtualPage GetPage(Guid applicationId, Guid id);
        VirtualPage GetPage(Guid applicationId, string name);
        PagedList<VirtualPage> GetPages(Guid applicationId, int start, int limit);
        PageContent GetPageContent(Guid applicationId, Guid pageId);
        ServiceResult DeletePageContent(Guid siteId, Guid pageId);
        PageContent GetPagePersonalization(Guid applicationId, string name);
        bool SavePageContent(PageContent personalization);
        bool SavePageTemplate(PageTemplate template);
        bool DeleteTemplate(string name);
        PageTemplate GetPageTemplate(Guid id);
        PageTemplate GetPageTemplate(string name);
        PagedList<PageTemplate> GetPageTemplates(int start, int limit);
        #endregion

        //#region menu
        //ServiceResult SaveMenu(VirtualMenu menu);
        //ServiceResult DeleteMenu(Guid menuId);
        //SingleResult<VirtualMenu> GetMenu(Guid menuId);
        //ListResult<VirtualMenu> GetMenus(Guid appId, Guid pageId);
        //ListResult<VirtualMenu> GetSubMenus(Guid menuId);
        //#endregion
    }
}
